open Castling;;

module CharPG = ParserGenerator (CharToken);;
open CharPG;;

let rec units = lazy !! (
	one_of ~name:"units" [
		"next", unit >> units;
		"end", epsilon]
) and unit = lazy !! (
	one_of ~name:"one_unit" [
		"a", unit_a;
		"b", unit_b;
		"p", element 'P' >> sequence_of (unit_a)]
) and unit_a = lazy !! (
	element '(' >> unit >> element ')'
) and unit_b = lazy !! (
	element 'B'
);;

debug := true;;
runtime_debug := true;;
generate units;;
